package cn.kpi.service.usualassessment.impl;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.transaction.interceptor.TransactionAspectSupport;

import cn.kpi.dao.usualassessment.UserUsAssTempDao;
import cn.kpi.entity.usualassessment.UserAndTempEntity;
import cn.kpi.entity.usualassessment.UserTemplateEntity;
import cn.kpi.entity.usualassessment.UserUsAssTempEntity;
import cn.kpi.service.usualassessment.IUserUsAssTempService;

@Service
public class UserUsAssTempServiceImpl implements IUserUsAssTempService  {
	@Autowired
	private UserUsAssTempDao userUsAssTempDao;
	
	
	public List<UserUsAssTempEntity> GetUserUsAssTempListByWhere(String where)throws Exception{
		try{
			return userUsAssTempDao.GetUserUsAssTempListByWhere(where);
		}
		catch(Exception ex){
			ex.printStackTrace();
			return null;
		}
	}
	public int GetUserUsAssTempListCountByWhere(String where)throws Exception{
		try{
			return userUsAssTempDao.GetUserUsAssTempListCountByWhere(where);
		}
		catch(Exception ex){
			ex.printStackTrace();
			return -1;
		}
	}
	@Transactional
	public int InsertBatchEntity(List<UserTemplateEntity> list)throws Exception{
		try{
			int result=0;
			result+=userUsAssTempDao.UpdateBatchEntity(list);
			result+=userUsAssTempDao.InsertBatchEntity(list);
			return result;
		}
		catch(Exception ex){
			ex.printStackTrace();
			TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
			return -1;
		}
	}
	public UserTemplateEntity GetUserUsAssTempById(Long userid)throws Exception{
		try{
			return userUsAssTempDao.GetUserUsAssTempById(userid);
		}
		catch(Exception ex){
			ex.printStackTrace();
			return null;
		}
	}
	public List<UserAndTempEntity> GetUserTempListByWhere(String where)throws Exception{
		try{
			return userUsAssTempDao.GetUserTempListByWhere(where);
		}
		catch(Exception ex){
			ex.printStackTrace();
			return null;
		}
	}
	public List<Map> GetUserTempOrgSummaryList()throws Exception{
		try{
			return userUsAssTempDao.GetUserTempOrgSummaryList();
		}
		catch(Exception ex){
			ex.printStackTrace();
			return null;
		}
	}
	
	public List<Map>  GetUserTempOrgSummaryListByWhere(String where)throws Exception{
		try{
			return userUsAssTempDao.GetUserTempOrgSummaryListByWhere(where);
		}
		catch(Exception ex){
			ex.printStackTrace();
			return null;
		}
	}
}
